package personal.pheonix.focus.dan.action;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import personal.pheonix.focus.dan.cache.redis.JedisClient;
import personal.pheonix.focus.dan.model.param.base.JsonData;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Created by Administrator on 2016/10/17.
 */
@Controller
public class MonitorController {
    private Logger logger = LogManager.getLogger(MonitorController.class);
    @Autowired
    private JedisClient jedisClient;
    @RequestMapping(value = "/isLive.action")
    public void isLive(HttpServletRequest req, HttpServletResponse resp) {
        try {
            jedisClient.set("test_redis","ok");
            resp.getOutputStream().write("ok".getBytes());
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
    @RequestMapping(value = "testJson.action")
    @ResponseBody
    public JsonData testJson(){
//        BaseConvert.checkPara(page);
//        LogSearchDto dto = LogConvert.of(para);
//        int count = sysLogDao.countFuzzySearch(dto);
//        if (count > 0) {
//            List<SysLog> list = sysLogDao.fuzzySearch(dto, page);
//            return PageResult.<SysLog>builder().total(count).data(list).build();
//        }
//        return PageResult.<SysLog>builder().build();
        logger.info("Info:"+jedisClient.get("test_redis"));
        return JsonData.success("test_redis");
    }
}
